import React from 'react';
import { Form, Input, Button } from 'antd';
import { UserOutlined, LockOutlined } from '@ant-design/icons';
import './index.css'
import http from '../../http/index'
const Login = (props) => {
    const handleSubmit = values => {
        http.post('/api/manage/user/login.do',{'username':values.username,'password':values.password}).then(res => {
            console.log(res)
            localStorage.setItem("user",JSON.stringify(res));
            props.history.push('/main/home')
        })
    };

    return (
        <div className='login'>
            <Form
                name="normal_login"
                className="login-form"
                initialValues={{
                    remember: true,
                }}
                onFinish={handleSubmit}
            >
                <Form.Item
                    name="username"
                    rules={[
                        {
                            required: true,
                            message: '请输入账号!',
                        },
                    ]}
                >
                    <Input prefix={<UserOutlined className="site-form-item-icon" />} placeholder="账号为 admin" />
                </Form.Item>
                <Form.Item
                    name="password"
                    rules={[
                        {
                            required: true,
                            message: '请输入密码!',
                        },
                    ]}
                >
                    <Input
                        prefix={<LockOutlined className="site-form-item-icon" />}
                        type="password"
                        placeholder="密码为 admin"
                    />
                </Form.Item>
                <Form.Item>
                    <Button type="primary" htmlType="submit" className="login-form-button">登录</Button>
                </Form.Item>
            </Form>
        </div>
    );
};

export default Login;